﻿<nav>
    <div class="top-row pl-4 navbar navbar-dark">
        <a class="navbar-brand" href="">BLAZOR DASHBOARD</a>
        <div>
            <button class="navbar-toggler" @onclick=LaunchSideBar>
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="navbar-toggler" @onclick=ToggleNavMenu>
                <span class="oi oi-excerpt" style="padding-right:2px;padding-left:2px;padding-bottom:2px;padding-top:5px;width:30px;height:30px;vertical-align: middle; background: no-repeat center center;background-size: 100% 100%;font-size:22px;font-weight:100"></span>
            </button>
        </div>
    </div>
    <div class="collapse">
        <ul class="nav flex-column">
            <li class="nav-item-side px-3">
                <NavLink class="nav-link" href="" Match=NavLinkMatch.All>
                    <span class="oi oi-home" aria-hidden="true"></span> Home
                </NavLink>
            </li>

            <li class="nav-item-side px-3">
                <NavLink class="nav-link" href="counter">
                    <span class="oi oi-plus" aria-hidden="true"></span> Counter
                </NavLink>
            </li>

        </ul>
    </div>
</nav>

<!--

<nav class=@(SlideIn ? "slidebar-nav" : "")>
    <div class="top-row pl-4 navbar navbar-dark">
        <a class="navbar-brand" href="">BLAZOR DASHBOARD</a>
        <div style=@(SlideIn ? "visibility:hidden" : "visibility:visible")>
            <button class="navbar-toggler" @onclick=LaunchSideBar>
                <span class="navbar-toggler-icon"></span>
            </button>
            <button class="navbar-toggler" @onclick=ToggleNavMenu>
                <span class="oi oi-excerpt" style="padding-right:2px;padding-left:2px;padding-bottom:2px;padding-top:5px;width:30px;height:30px;vertical-align: middle; background: no-repeat center center;background-size: 100% 100%;font-size:22px;font-weight:100"></span>
            </button>
        </div>
    </div>
    <div class=@(CollapseSideMenu ? "collapse" : "") @onclick=ToggleSideMenu>
        <ul class="nav flex-column">
            <li class="nav-item-side px-3">
                <NavLink class="nav-link" href="" Match=NavLinkMatch.All>
                    <span class="oi oi-home" aria-hidden="true"></span> Home
                </NavLink>
            </li>

            <li class="nav-item-side px-3">
                <NavLink class="nav-link" href="counter">
                    <span class="oi oi-plus" aria-hidden="true"></span> Counter
                </NavLink>
            </li>

        </ul>
    </div>
</nav>
-->

@functions {
    [Parameter]
    public bool SlideIn { get; set; } = false;

    [Parameter]
    public bool CollapseSideMenu { get; set; } = true;

    void ToggleSideMenu()
    {
        CollapseSideMenu = !CollapseSideMenu;
    }

    //bool collapseNavMenu = true;

    void ToggleNavMenu()
    {
        //collapseNavMenu = !collapseNavMenu;
        BlazorDashboard.XSingleton.NavBarDisplay = !BlazorDashboard.XSingleton.NavBarDisplay;
        //StateHasChanged();
        ToggleNavMenuChanged();
    }

    [Parameter]
    public Action ToggleNavMenuChanged { get; set; }

    [Parameter]
    public Action SlideInSideBarTriggered { get; set; }

    public async Task LaunchSideBar()
    {
        BlazorDashboard.XSingleton.NavBarDisplay = false;
        ToggleNavMenuChanged();
        //deprecated
        //await JSRuntime.Current.InvokeAsync<bool>("LaunchSideBar");

        SlideInSideBarTriggered();
    }

    [JSInvokable]
    public static string SayHello() => $"Hello!";

    [JSInvokable]
    public static void RestoreTopBar()
    {
    BlazorDashboard.XSingleton.NavBarDisplay = false;
    }

    [JSInvokable]
    public static void HideTopBar()
    {
    BlazorDashboard.XSingleton.NavBarDisplay = false;
    }
    [JSInvokable]
    public static void ShowTopBar()
    {
    BlazorDashboard.XSingleton.NavBarDisplay = true;
    }

    }
